From b9db4d7061a08bf82a25222074065cce71973d0c Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20H=C3=A4rdeman?= Date: Sun, 23 Nov 2025 15:12:01 +0100 Subject: [PATCH] dhcpv6: handle realloc failure MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Another realloc failure case. Signed-off-by: David Härdeman Link: https://github.com/openwrt/odhcpd/pull/320 Signed-off-by: Álvaro Fernández Rojas --- src/dhcpv6-ia.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/dhcpv6-ia.c b/src/dhcpv6-ia.c index b884f9a..32b652d 100644 --- a/src/dhcpv6-ia.c +++ b/src/dhcpv6-ia.c @@ -1236,8 +1236,9 @@ proceed: hdr->msg_type == DHCPV6_MSG_REQUEST || hdr->msg_type == DHCPV6_MSG_REBIND)) { if ((!(a->flags & OAF_STATIC) || !a->hostname) && hostname_len > 0) { - a->hostname = realloc(a->hostname, hostname_len + 1); - if (a->hostname) { + char *hostname = realloc(a->hostname, hostname_len + 1); + if (hostname) { + a->hostname = hostname; memcpy(a->hostname, hostname, hostname_len); a->hostname[hostname_len] = 0; -- 2.30.2